package com.newbingo.dto;

import java.util.Date;

import com.newbingo.entity.PeriodGame;

public class PeriodGameDto {
	private Integer pgno;
	private Integer pgnum;
	private Date periodTime;
	private Integer isDraw;
	// 当前时间距离官方开奖时间，获取投注倒计时和开奖倒计时
	private Integer endBettingInterval;
	//将服务器当前时间发送到页面，进行时间倒计时验证
	private Date serverCurrentTime=new Date();

	/*
	 * 将periodGame转换成periodGameDto对象
	 */
	public PeriodGameDto changeToDto(PeriodGame periodGame) {
		PeriodGameDto dto = new PeriodGameDto();
		dto.setPgno(periodGame.getPgno());
		dto.setPgnum(periodGame.getPgnum());
		dto.setPeriodTime(periodGame.getPeriodTime());
		Date now = new Date();
		// 获取投注倒计时距离设定时间间隔
		if(periodGame.getPeriodTime()!=null){
			dto.setEndBettingInterval((int) ((periodGame.getPeriodTime()
					.getTime() - now.getTime()) / 1000)
					- periodGame.getGameTable().getOperationTime()
							.getEndBettingTimeout());
			if (dto.getEndBettingInterval() <= 0)
				dto.setEndBettingInterval(0);
		}
		return dto;
	}

	public Integer getPgno() {
		return pgno;
	}

	public void setPgno(Integer pgno) {
		this.pgno = pgno;
	}

	public Integer getPgnum() {
		return pgnum;
	}

	public void setPgnum(Integer pgnum) {
		this.pgnum = pgnum;
	}

	public Date getPeriodTime() {
		return periodTime;
	}

	public void setPeriodTime(Date periodTime) {
		this.periodTime = periodTime;
	}

	public Integer getIsDraw() {
		return isDraw;
	}

	public void setIsDraw(Integer isDraw) {
		this.isDraw = isDraw;
	}

	public Integer getEndBettingInterval() {
		return endBettingInterval;
	}

	public void setEndBettingInterval(Integer endBettingInterval) {
		this.endBettingInterval = endBettingInterval;
	}

	public Date getServerCurrentTime() {
		return serverCurrentTime;
	}

	public void setServerCurrentTime(Date serverCurrentTime) {
		this.serverCurrentTime = serverCurrentTime;
	}

}
